//=============================================================================
// DirectInput.h by Frank Luna (C) 2005 All Rights Reserved.
//
// Wraps initialization of immediate mode Direct Input, and provides 
// information for querying the state of the keyboard and mouse.
//=============================================================================
#ifndef __DXENGINEINPUT_H__
#define __DXENGINEINPUT_H__

#include "DXEngineCommon.h"

#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#include <boost/smart_ptr/shared_ptr.hpp>


class CDXEngineInput
{
public:
	CDXEngineInput();
	~CDXEngineInput();

	bool Init(HINSTANCE appInst, HWND hWin, DWORD keyboardCoopFlags, DWORD mouseCoopFlags);
	void Poll();
	bool KeyDown(char key) { return (m_KeyboardState[key] & 0x80) != 0; }
	bool MouseButtonDown(int button) { return (m_MouseState.rgbButtons[button] & 0x80) != 0; }
	void MouseClearState(int button) { m_MouseState.rgbButtons[button] = 0; }
	long MouseDX() { return m_MouseState.lX; }
	long MouseDY() { return m_MouseState.lY; }
	long MouseDZ() { return m_MouseState.lZ; }
	long MouseX() { return m_MousePosition.x; }
	long MouseY() { return m_MousePosition.y; }
	POINT MousePos() { return m_MousePosition; }

private:
	CDXEngineInput(const CDXEngineInput& rhs);
	CDXEngineInput& operator=(const CDXEngineInput& rhs);
		
private:
	IDirectInput8*       m_DInput;

	IDirectInputDevice8* m_Keyboard;
	char                 m_KeyboardState[256]; 

	IDirectInputDevice8* m_Mouse;
	DIMOUSESTATE2        m_MouseState;
	
	HWND				m_HWin;
	POINT				m_MousePosition;
};
typedef boost::shared_ptr<CDXEngineInput> DXEngineInputPtr;


#endif // __DXENGINEINPUT_H__


